const Sequelize = require('sequelize')
const sequelize = require('../libs/db')
class Role extends Sequelize.Model {}
Role.init(
  {
    roleId: {
      field: 'id',
      type: Sequelize.BIGINT,
      primaryKey: true,
      autoIncrement: true
    },
    roleName: {
      field: 'role_name',
      type: Sequelize.STRING(100),
      allowNull: false,
      unique: true,
      comment: '角色名称'
    },
    permission: {
      field: 'permission',
      type: Sequelize.TEXT,
      allowNull: false,
      comment: 'json存储的权限列表'
    },
    createdAt: {
      field: 'created_at',
      type: Sequelize.BIGINT
    },
    updatedAt: {
      field: 'updated_at',
      type: Sequelize.BIGINT
    }
  },
  {
    sequelize,
    modelName: 'role',
    tableName: 'role'
  }
)

module.exports = Role
